#include <vector>
#include <queue>

using namespace std;

class Solution {
public:
    vector<int> maxSlidingWindow(vector<int>& nums, int k)
    {
        vector<int> res;
        priority_queue<pair<int, int>> pq; // num : index
        int n = nums.size();
        int left = 0, right = 0;
        while (right < n)
        {
            if (right - left < k) {
                pq.push(make_pair(nums[right], right));
            }
            else {
                while (!(pq.top().second >= left && pq.top().second < right)) {
                        pq.pop();
                }
                res.push_back(pq.top().first);
                ++left;
            }
            ++right;
        }
        return res;
    }
};

int main()
{
   Solution s;
   vector<int> vec{1,3,-1,-3,5,3,6,7};
   s.maxSlidingWindow(vec, 3);
   return 0;
}
